package cn.thinkjoy.LawDataForExcel.email;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by thinkjoy on 2017/6/27.
 */

public class EmailMessage {

    //发件人的邮箱和密码
    private static final String MyEmailAccount="13750035835@163.com";
    private static final String MyEmailPasswd="liangyiyun0429";
    public static final String MyEmailHost="smtp.163.com";//SMTP服务器地址
    public static final String ReceiveMailAccount="541535798@qq.com";//收件人邮箱

    public void sendMail(String filepath){
        try {
            String currentDate=new SimpleDateFormat("yyyy/MM/dd").format(new Date());
            MailUtils.sendMsg(MyEmailAccount,MyEmailPasswd,MyEmailHost,
                    ReceiveMailAccount,currentDate+":最新生成的交通违法文件,请注意查收","您好,请接收"+currentDate+"最新生成的交通违法文件",filepath);
            System.out.println("邮件发送成功");
            File f=new File(filepath);
            f.delete();
            System.out.println("删除压缩文件");
        } catch (Exception e) {
            System.out.println("邮件发送失败!");
            e.printStackTrace();
        }
    }
}
